package com.ibuu.demos.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ibuu.demos.mapper.AdminMapper;
import com.ibuu.demos.mapper.UserMapper;
import com.ibuu.demos.pojo.Admin;
import com.ibuu.demos.pojo.User;
import com.ibuu.demos.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean login(String username, String password) {
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        queryWrapper.eq("password", password);
        queryWrapper.eq("status", "1");
        Admin admin = baseMapper.selectOne(queryWrapper);
        return admin != null;
    }

    @Override
    public Page<User> select() {
        Page<User> userPage = new Page<>();
        Page<User> userPage1 = userMapper.selectPage(userPage, null);
        return userPage1;
    }
}
